package com.bmf.module.examination.controller;

import com.bmf.module.examination.service.BigQuestionService;
import com.bmf.module.examination.vo.BigQuestionCreateVo;
import com.bmf.module.examination.vo.BigQuestionResultVo;
import com.bmf.module.examination.vo.BigQuestionUpdateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import com.bmf.core.result.R;

/**
 * (BigQuestion)表控制层
 *
 * @author makejava
 * @since 2022-11-29 17:51:48
 */
@RestController
@RequestMapping("bigQuestion")
@Api(tags = {"创建大题接口"})
public class BigQuestionController{
    /**
     * 服务对象
     */
    @Resource
    private BigQuestionService bigQuestionService;

    /**
     * 分页查询所有数据
     *
     * @return 所有数据
     */
    @GetMapping("/{examinationId}")
    @ApiOperation(value = "查询大题")
    public R<List<BigQuestionResultVo>> selectAll(@PathVariable("examinationId")Integer examinationId) {
        List<BigQuestionResultVo> list = bigQuestionService.selectAll(examinationId);
        return R.success(list);
    }

    /**
     * 新增大题
     *
     * @param bigQuestionCreateVo 实体对象
     * @return 新增结果
     */
    @PostMapping
    @ApiOperation(value = "新增大题")
    public R<Integer> insert(@RequestBody BigQuestionCreateVo bigQuestionCreateVo) {
        return R.success(bigQuestionService.insert(bigQuestionCreateVo));
    }

    /**
     * 修改数据
     *
     * @param bigQuestionUpdateVo 实体对象
     * @return 修改结果
     */
    @PutMapping
    @ApiOperation(value = "修改大题")
    public R<Void> update(@RequestBody BigQuestionUpdateVo bigQuestionUpdateVo) {
        bigQuestionService.update(bigQuestionUpdateVo);
        return R.ok();
    }

    /**
     * 删除数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @DeleteMapping
    @ApiOperation(value = "删除大题")
    public R<Void> delete(@RequestBody List<Integer> ids) {
        bigQuestionService.delete(ids);
        return R.ok();
    }
}

